from fastapi import APIRouter, Depends, Request
from sqlalchemy.orm import Session
from ..database import get_db
from ..models.account import Account, Environment
from fastapi.templating import Jinja2Templates

router = APIRouter(prefix="/accounts")
templates = Jinja2Templates(directory="app/templates")

@router.get("/")
async def list_accounts(request: Request, db: Session = Depends(get_db)):
    accounts = db.query(Account).all()
    environments = db.query(Environment).all()
    return templates.TemplateResponse(
        "account/list.html",
        {
            "request": request,
            "accounts": accounts,
            "environments": environments,
            "title": "账号管理"
        }
    ) 